//
//  ZYYbackView.m
//  c33
//
//  Created by Visitor.zs on 17/5/4.
//  Copyright © 2017年 coder_zyy. All rights reserved.
//

#import "ZYYbackView.h"

@implementation ZYYbackView

+(instancetype)backViewWithImageName:(NSString *)image highlightImagename:(NSString *)hImage titleImage:(NSString *)title target:(id)atarget action:(SEL)action
{

    // 添加按钮
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    // 设置图片状态图片
    [btn setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    // 高亮状态图片
    [btn setImage:[UIImage imageNamed:hImage] forState:UIControlStateHighlighted];
    [btn setTitle:title forState:UIControlStateNormal];
    btn.titleLabel.font = [UIFont systemFontOfSize:14];
    
    //    [btn setTitleColor:[UIColor blackColor] forState:0];
    //    [btn setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
    
    // 自动适应大小
    [btn sizeToFit];
    
    // 设置回调目标
    [btn addTarget:atarget action:action forControlEvents:UIControlEventTouchUpInside];
    // 外面包一层View 以防越界响应
    ZYYbackView *v = [ZYYbackView new];
    v.frame = btn.bounds;
    [v addSubview:btn];
    return v;



}

@end
